<?php
session_start ();

if (! empty ( $_SESSION ['username'] ) && $_SESSION ['username'] == "admin") {
	if (! empty ( $_POST ['username'] ) && ! empty ( $_POST ['numbid'] )) {
		$user = addslashes ( $_POST ['username'] );
		$bidnum = ( int ) $_POST ['numbid'];
		
		include_once '../../pages/config.php';
		
		$connection = mysql_connect ( $host, $username, $password ) or die ( json_encode ( array (
				'success' => false,
				'errors' => "could not connect to MySql" . mysql_error () 
		) ) );
		mysql_select_db ( "mydb", $connection ) or die ( json_encode ( array (
				'success' => false,
				'errors' => "could not connect to MySql" . mysql_error () 
		) ) );
		$query = "UPDATE User SET balance = balance + " . $bidnum . " WHERE username = '" . $user . "'";
		
		$result = mysql_query ( $query, $connection );
		
		if (! $result) {
			die ( json_encode ( array (
					'success' => false,
					'errors' => 'Query not successful ' 
			) ) );
		}
		$effected = mysql_num_rows ( $result );
		
		if ($effected) {
			die ( json_encode ( array (
					'success' => true 
			) ) );
		}
	}
} else {
	echo "ksdjfie";
	exit ();
}
;
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>TMDT Project Admin</title>
<link rel="stylesheet" href="/admin/resources/css/reset.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="/admin/resources/css/style.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="/admin/resources/css/jquery-ui.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="/admin/resources/css/invalid.css"
	type="text/css" media="screen" />
<script type="text/javascript"
	src="/admin/resources/scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/scripts/jquery-1.8.3.min.js"></script>
<script type="text/javascript"
	src="/admin/resources/scripts/simpla.jquery.configuration.js"></script>
<script type="text/javascript" src="/admin/resources/scripts/facebox.js"></script>
<script type="text/javascript"
	src="/admin/resources/scripts/jquery.wysiwyg.js"></script>
<script type="text/javascript"
	src="/admin/resources/scripts/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript"
	src="/admin/resources/scripts/jquery-date-picker.js"></script>

<script>
$('document').ready(function(){
	$('.datepicker').datetimepicker({

		dateFormat: "dd-mm-yy",
		minDate: getFormattedDate(new Date()), 
		timeFormat: "hh:mm:ss"
	});

	function getFormattedDate(date) {
	    var day = date.getDate();
	    var month = date.getMonth() + 1;
	    var year = date.getFullYear().toString().slice(2);
	    return day + '-' + month + '-' + year;
	}}
	);

</script>

</head>
<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->

		<div id="sidebar">
			<div id="sidebar-wrapper">
				<!-- Sidebar with logo and menu -->

				<h1 id="sidebar-title">
					<a href="#">TMDT Project Admin</a>
				</h1>

				<!--  Logo (221px wide) -->
				<a href="#"><img id="logo" src="/admin/resources/images/logo.png"
					alt="Simpla Admin logo" /></a>





				<ul id="main-nav">
					<!-- Accordion Menu -->

					<li><a href="/admin/index.php" class="nav-top-item no-submenu"> <!-- Add the class "no-submenu" to menu items with no sub menu -->
							Dashboard
					</a></li>

					<li><a href="#" class="nav-top-item current"> <!-- Add the class "current" to current menu item -->
							Auctions
					</a>
						<ul>

							<li><a id="create_auction" class="current"
								href="createauction.php">Create New Auction</a></li>
							<li><a id="all_auctions" href="allauctions.php">All Auctions</a></li>
							<!-- Add class "current" to sub menu items also -->

						</ul></li>

					<li><a href="#" class="nav-top-item"> Products </a>
						<ul>
							<li><a href="createproduct.php">Create New Product</a></li>
							<li><a href="allproducts.php">All Products</a></li>
						</ul></li>

					<li><a href="#" class="nav-top-item"> Users </a>
						<ul>
							<li><a href="allusers.php">All users</a></li>
							<li><a href="topup.php">Top-Bid Users</a></li>

						</ul></li>

					<li><a href="#" class="nav-top-item"> Orders </a>
						<ul>
							<li><a href="allorders.php">All orders</a></li>

						</ul></li>

					<li><a href="#" class="nav-top-item"> Settings </a>
						<ul>
							<li><a href="#">General</a></li>
							<li><a href="adminprofile.php">My Profile</a></li>

						</ul></li>

				</ul>
				<!-- End #main-nav -->





			</div>
		</div>
		<!-- End #sidebar -->
		<div id="clear"></div>
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<!-- Page Head -->
			<h2>Welcome</h2>
			<p id="page-intro">What would you like to do?</p>

			<ul class="shortcut-buttons-set">

				<li><a class="shortcut-button" href="/admin/pages/createauction.php"><span>
							<img src="/admin/resources/images/icons/pencil_48.png" alt="icon" /><br />
							Create new Auction
					</span></a></li>

				<li><a class="shortcut-button" href="/admin/pages/createproduct.php"><span>
							<img
							src="/admin/resources/images/icons/paper_content_pencil_48.png"
							alt="icon" /><br /> Create new Product
					</span></a></li>


				<li><a class="shortcut-button" href="/admin/pages/allauctions.php"><span>
							<img src="/admin/resources/images/icons/clock_48.png" alt="icon" /><br />
							All Auctions
					</span></a></li>

				<li><a class="shortcut-button" href="/admin/pages/allorders.php"
					rel="modal"><span> <img
							src="/admin/resources/images/icons/comment_48.png" alt="icon" /><br />
							All Orders
					</span></a></li>

			</ul>
			<!-- End .shortcut-buttons-set -->
			<div class="clear"></div>
			<!-- End .clear -->
			<noscript>
				<!-- Show a notification if the user has disabled javascript -->
				<div class="notification error png_bg">
					<div>
						Javascript is disabled or is not supported by your browser. Please
						<a href="http://browsehappy.com/"
							title="Upgrade to a better browser">upgrade</a> your browser or <a
							href="http://www.google.com/support/bin/answer.py?answer=23852"
							title="Enable Javascript in your browser">enable</a> Javascript
						to navigate the interface properly.
					</div>
				</div>
			</noscript>







			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box -->

				<div class="content-box-header">

					<h3>Top Up</h3>

					<ul class="content-box-tabs">

						<li><a href="#create_auction_tab">Top Up</a></li>
					</ul>


					<div class="clear"></div>
					<!-- End .clear -->
				</div>
				<!-- End .content-box-header -->

				<div class="content-box-content">

					<div class="tab-content default-tab" id="create_auction_tab">

						<form action="<?php echo $_SERVER['PHP_SELF'] ;?>" method="post">

							<fieldset>
								<!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
								<p>
									<label>Username(*)</label> <input
										class="text-input medium-input" type="text" id="username"
										name="username" value="" /> <span id="username_message"
										class="validate_err"></span>
									<!-- Classes for input-notification: success, error, information, attention -->
									<br /> <small>Name for this auction</small>
								</p>


								<p>
									<label>Number of bid(*)</label> <input
										class="text-input small-input" type="text" id="numbid"
										name="numbid" value="" /> <span id="quantity_message"
										class="validate_err"></span>
									<!-- Classes for input-notification: success, error, information, attention -->
									<br /> <small>Number of bid</small>
								</p>


								<p>
									<input class="button" type="submit" value="Create" /> <a
										href="/admin/index.php"><input class="button" value="Cancel" />
									</a>
								</p>

							</fieldset>

							<div class="clear"></div>
							<!-- End .clear -->

						</form>

					</div>
					<!-- End #tab2 -->
				</div>
				<!-- End .content-box-content -->
			</div>
			<!-- End .content-box -->


			<div class="clear"></div>

		</div>
		<!-- End #main-content -->
	</div>
</body>
</html>

